<template>
  <div class="my-class-container">
    <!-- 返回按钮 -->
    <div class="back-button-container">
      <el-button 
        type="primary" 
        :icon="ArrowLeft" 
        circle 
        @click="handleBack"
        class="back-button"
        title="返回首页"
      />
    </div>
    
    <div class="my-class-content">
      <!-- 标题和返回按钮容器 -->
      <div class="title-container">
        <h1 class="my-class-title">我的课程</h1>
      </div>
      
      <!-- 查看学习进度按钮 -->
      <div class="progress-button-container">
        <el-button 
          type="success" 
          size="large" 
          :icon="TrendCharts"
          @click="handleViewProgress"
          class="progress-button"
        >
          查看学习进度
        </el-button>
      </div>
      
      <!-- 课程卡片网格 -->
      <div class="course-grid">
        <div 
          v-for="(course, index) in myCourses" 
          :key="index"
          class="course-card"
          @click="handleCourseClick(course)"
        >
          <div class="course-header">
            <span class="course-tag">{{ course.tag }}</span>
          </div>
          <div class="course-body">
            <h3 class="course-title">{{ course.title }}</h3>
            <p class="course-description">{{ course.description }}</p>
          </div>
          <div class="course-footer">
            <el-button type="primary" size="small" round>
              开始学习
            </el-button>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { ArrowLeft, TrendCharts } from '@element-plus/icons-vue'
import { useRouter } from 'vue-router'
import { reactive } from 'vue'

// 组件名称
defineOptions({
  name: 'MyClassPage'
})

// 页面标题
document.title = '我的课程 - 网络云实验室'

// 路由实例
const router = useRouter()

// 我的课程数据
const myCourses = reactive([
  {
    title: 'Vue.js 高级组件设计',
    description: '学习如何设计可复用的Vue组件和高效状态管理',
    tag: '前端'
  },
  {
    title: 'Spring Boot微服务架构',
    description: '从零开始构建微服务架构应用',
    tag: 'Java后端'
  },
  {
    title: 'MySQL性能优化实战',
    description: '数据库索引设计和查询优化技巧',
    tag: '数据库'
  },
  {
    title: '数据结构与算法：从入门到精通',
    description: '掌握常见算法和解题技巧',
    tag: '算法'
  },
  {
    title: 'Photoshop创意设计',
    description: '学习UI设计和图像处理技巧',
    tag: 'PS'
  },
  {
    title: 'Adobe Premiere视频剪辑教程',
    description: '从基础到高级的视频剪辑技术',
    tag: '视频剪辑'
  },
  {
    title: 'Java并发编程实践',
    description: '掌握Java多线程和并发处理的核心技术',
    tag: 'Java后端'
  },
  {
    title: 'React Hooks与状态管理',
    description: '现代React应用开发与状态管理模式',
    tag: '前端'
  }
])

// 返回首页
const handleBack = () => {
  router.push('/home')
}

// 课程点击事件
const handleCourseClick = (course: any) => {
  console.log('点击课程:', course.title)
  // 这里可以添加跳转到具体课程页面的逻辑
}

// 查看学习进度
const handleViewProgress = () => {
  router.push('/learning-progress')
}
</script>

<style scoped>
.my-class-container {
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
}

.back-button-container {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 1000;
}

.back-button {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  backdrop-filter: blur(10px);
  color: white;
  transition: all 0.3s ease;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.back-button:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.back-button:active {
  transform: scale(0.95);
}

.my-class-content {
  text-align: center;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  padding: 40px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  max-width: 1200px;
  width: 100%;
}

/* 标题容器 */
.title-container {
  margin-bottom: 30px;
  animation: fadeInUp 0.8s ease-out;
}

.my-class-title {
  font-size: 48px;
  font-weight: 700;
  color: white;
  margin: 0;
  text-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
  letter-spacing: 2px;
}

.progress-button-container {
  margin-bottom: 40px;
  animation: fadeInUp 1s ease-out;
}

.progress-button {
  background: linear-gradient(135deg, #52c41a 0%, #389e0d 100%);
  border: none;
  padding: 12px 24px;
  font-size: 16px;
  font-weight: 600;
  border-radius: 25px;
  box-shadow: 0 4px 15px rgba(82, 196, 26, 0.3);
  transition: all 0.3s ease;
}

.progress-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(82, 196, 26, 0.4);
}

/* 课程网格布局 */
.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  margin-top: 30px;
}

/* 课程卡片样式 */
.course-card {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.2);
  animation: fadeInUp 0.8s ease-out;
}

.course-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.15);
  background: rgba(255, 255, 255, 1);
}

.course-header {
  margin-bottom: 16px;
}

.course-tag {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.course-body {
  margin-bottom: 20px;
}

.course-title {
  font-size: 18px;
  font-weight: 700;
  color: #2c3e50;
  margin: 0 0 12px 0;
  line-height: 1.4;
}

.course-description {
  font-size: 14px;
  color: #7f8c8d;
  line-height: 1.6;
  margin: 0;
}

.course-footer {
  text-align: center;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 响应式设计 */
@media (max-width: 768px) {
  .title-container {
    gap: 15px;
  }
  
  .my-class-title {
    font-size: 36px;
  }
  
  .my-class-content {
    padding: 30px 20px;
  }
  
  .course-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  
  .course-card {
    padding: 20px;
  }
}

@media (max-width: 480px) {
  .title-container {
    gap: 10px;
  }
  
  .my-class-title {
    font-size: 28px;
  }
  
  .course-title {
    font-size: 16px;
  }
  
  .course-description {
    font-size: 13px;
  }
}
</style> 